
package com.showcai.controller.organization;

import com.showcai.controller.base.WeChatBaseController;
import com.showcai.def.Constant;
import com.showcai.module.Organization;
import com.showcai.myRunTime.MyRunTimeExcption;
import com.showcai.result.ResultObj;
import com.showcai.service.CertificateService;
import com.showcai.service.OrganizationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

/**
 * Created by lutao on 2017/7/14.
 */
@RequestMapping("/organization")
@Controller
public class OrganizationController extends WeChatBaseController {
 @Autowired
 OrganizationService organizationService;

    /**
     * 验证卡券
     *
     * @return
     */
    @RequestMapping(value = "/login", method = RequestMethod.POST)
    @ResponseBody
    public String userGain(Organization organization ) {
        ResultObj resultObj = new ResultObj();

          organization=  organizationService.loginOrganization(organization);
          session.setAttribute(Constant.SESSION_KEY_ORGANIZATION_USER_LOGIN,organization);
        resultObj.setMsg("操作成功！");

        return resultObj.toJson();
    }

    /**
     * 卡券验证页面
     * @return
     */
    @RequestMapping(value = "/organizationLogin")
    public ModelAndView organizationLogin() {
        ModelAndView mov = new ModelAndView();
        String views = "organization/web/login";
        if (getIsMobile()) {
            views = "organization/wap/login";
        }
        mov.setViewName(views);
        return mov;
    }

}
